/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ve.com.cantv.worktables.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Ghust
 */
@Entity
@Table(name = "roltask")
@NamedQueries({@NamedQuery(name = "Roltask.findAll", query = "SELECT r FROM Roltask r"), @NamedQuery(name = "Roltask.findByIdrol", query = "SELECT r FROM Roltask r WHERE r.roltaskPK.idrol = :idrol"), @NamedQuery(name = "Roltask.findByIdtask", query = "SELECT r FROM Roltask r WHERE r.roltaskPK.idtask = :idtask"), @NamedQuery(name = "Roltask.findByDatechange", query = "SELECT r FROM Roltask r WHERE r.datechange = :datechange")})
public class Roltask implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RoltaskPK roltaskPK;
    @Column(name = "datechange")
    @Temporal(TemporalType.DATE)
    private Date datechange;
    @JoinColumn(name = "idrol", referencedColumnName = "idrol", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Rol rol;
    @JoinColumn(name = "idtask", referencedColumnName = "idtask", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Task task;
    @JoinColumn(name = "iduser", referencedColumnName = "iduser")
    @ManyToOne
    private UUser iduser;

    public Roltask() {
    }

    public Roltask(RoltaskPK roltaskPK) {
        this.roltaskPK = roltaskPK;
    }

    public Roltask(int idrol, int idtask) {
        this.roltaskPK = new RoltaskPK(idrol, idtask);
    }

    public RoltaskPK getRoltaskPK() {
        return roltaskPK;
    }

    public void setRoltaskPK(RoltaskPK roltaskPK) {
        this.roltaskPK = roltaskPK;
    }

    public Date getDatechange() {
        return datechange;
    }

    public void setDatechange(Date datechange) {
        this.datechange = datechange;
    }

    public Rol getRol() {
        return rol;
    }

    public void setRol(Rol rol) {
        this.rol = rol;
    }

    public Task getTask() {
        return task;
    }

    public void setTask(Task task) {
        this.task = task;
    }

    public UUser getIduser() {
        return iduser;
    }

    public void setIduser(UUser iduser) {
        this.iduser = iduser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roltaskPK != null ? roltaskPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Roltask)) {
            return false;
        }
        Roltask other = (Roltask) object;
        if ((this.roltaskPK == null && other.roltaskPK != null) || (this.roltaskPK != null && !this.roltaskPK.equals(other.roltaskPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.com.cantv.worktables.ejb.entity.Roltask[roltaskPK=" + roltaskPK + "]";
    }

}
